<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('修改学生信息')" />
</head>
<body class="white-bg">
	<div class="wrapper wrapper-content animated fadeInRight ibox-content">
		<form class="form-horizontal m" id="form-stu-edit" >
			<input name="id"  type="hidden"  th:value="${id}" />
			<input name="stuId"  type="hidden"  th:value="${stuId}" />
			<div class="row">
				<div class="col-xs-6">
					<div class="form-group">
						<label class="col-sm-3 control-label is-required">到校时间：</label>
						<div class="col-sm-8">
							<input class="form-control" type="text" name="newStuArriveTime" autocomplete="off" id="newStuArriveTime" required  th:value="${per==null?'':#dates.format(per.newStuArriveTime, 'yyyy-MM-dd')}">
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="col-sm-3 control-label is-required">到校方式：</label>
						<div class="col-sm-8">

							<select name="newStuArriveType" class="form-control m-b">
								<option   th:value="飞机" th:field="*{per.newStuArriveType}">飞机</option>
								<option   th:value="火车" th:field="*{per.newStuArriveType}">火车</option>
								<option   th:value="汽车" th:field="*{per.newStuArriveType}">汽车</option>
							</select>
						</div>
					</div>
				</div>

			</div>
			<div class="row">
				<div class="col-xs-6">
					<div class="form-group">
						<label class="col-sm-3 control-label">航班/车次：</label>
						<div class="col-sm-8">
							<input class="form-control" type="text" id="newStuFlightNumber" name="newStuFlightNumber" th:value="${per==null?'':per.newStuFlightNumber}">
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="col-sm-3 control-label">陪同人数：</label>
						<div class="col-sm-8">
							<input class="form-control" type="text" id="newStuAccompany" name="newStuAccompany" th:value="${per==null?'':per.newStuAccompany}">
						</div>
					</div>
				</div>

			</div>
			<div class="row">
				<div class="col-xs-6">
					<div class="form-group">
						<label class="col-sm-3 control-label">联系方式(学生手机)：</label>
						<div class="col-sm-8">
							<input class="form-control" type="text" name="newStuPhone" required th:value="${per==null?'':per.newStuPhone}">
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="col-sm-3 control-label is-required">紧急联系人(家长手机)：</label>
						<div class="col-sm-8">
							<input class="form-control" type="text" name="newStuFamilyPhone" required th:value="${per==null?'':per.newStuFamilyPhone}">
						</div>
					</div>
				</div>

			</div>
		</form>
	</div>
	<th:block th:include="include :: footer" />
	<script type="text/javascript">
		var prefix = ctx + "common/personal";
	
		$("#form-stu-edit").validate({
			rules:{
                newStuPhone:{
                    checkPhone:true
				},
                newStuFamilyPhone:{
                    checkPhone:true
				},
                newStuArriveType:{
                    isFangShi:true
                },
                newStuFlightNumber:{
                    isCeCi:true
                }
			},
			focusCleanup: true
		});
		
		function submitHandler() {
	        if ($.validate.form()) {
	        	$.operate.save(prefix + "/edit", $('#form-stu-edit').serialize());
	        }
	    }
        layui.use('laydate', function () {
            var laydate = layui.laydate;
            var startDate = laydate.render({
                elem: '#newStuArriveTime',
                theme: 'molv',
                trigger: 'click',
                done: function (value, date) {

                }
            });
        });

        $(function() {
            jQuery.validator.addMethod("checkPhone", function (value, element){
                return this.optional(element) || checkPhone(value);
            },"请正确输入您的手机号码");
            jQuery.validator.addMethod("checkPhone", function (value, element){
                return this.optional(element) || checkPhone(value);
            },"请正确输入您的手机号码");
            jQuery.validator.addMethod("isFangShi", function (value, element){
                return this.optional(element) || fangshi(value);
            },"请正确输入飞机、火车或者汽车");
            jQuery.validator.addMethod("isCeCi", function (value, element){
                return this.optional(element) || ceci(value);
            },"请正确输入正确的航班号或火车号");

            function checkPhone(value){
                if( /^1[3|4|5|7|8][0-9]{9}$/.test(value)){
                    return true;
                }
                return false
            }
            function fangshi(value) {
                if(value=="火车"||value=="飞机"||value=="汽车")
				{
                    return true
				}
                return false
            }
            function ceci(value) {
                if (/([GDKZTCYLS1]\d{1,4}|\d{1,4})/.test(value)||/^[A-Z\d]{2}\d{4}$/.test(value)||value=="")
				{
                  return true
				}
				return false
            }
        })
	</script>
</body>
</html>
